#!/bin/bash

IP=$1;
PORT=$2;
OUTPUT=$3;
QUIET=$4

if [ -f $1 ];
then
	IP=" -w $1"
fi

echo $@;
if [ $# -lt 3 ];
then
 echo  "Args: zmap-continue-scan ip[CIRP] port output"
 echo  "you just type argc : $#"; 
 exit 0;
fi

echo $IP;
old=0
for i in {1..100};
do
	echo -n "$(sudo zmap -p $PORT  -T 10 $IP  -P 2 -v 0 $QUIET  -o - | grep "^\d"  >> $OUTPUT)";
	
	p=$(($i/2));
	printf "progress:[%-50s]%d%% count :%d\r" $b $p $i;
	if [ $old -lt $p ];
	then
		b=#$b;
	fi
	old=$p
done
